import { h } from 'vue';
import { ElTag } from 'element-plus';
import { BasicColumn } from '@/design/components/Table';
import { TableImg } from '@/components/TableImg';

export const columns: BasicColumn[] = [
  {
    label: '账号',
    prop: 'uid',
  },
  {
    label: '头像',
    prop: 'face',
    render({ row: record }) {
      return (
        record.face &&
        h(TableImg, {
          imgList: [record.face],
          imageProps: {
            class: 'w-10',
          },
        })
      );
    },
  },
  {
    label: '真实姓名',
    prop: 'realName',
  },
  {
    label: '手机号',
    prop: 'mobile',
  },
  {
    label: '邮箱',
    prop: 'email',
  },
  {
    label: '性别',
    prop: 'gender',
    render({ row: record }) {
      return h(
        ElTag,
        {
          type: record.gender === 'MALE' ? 'info' : 'danger',
        },
        {
          default: () => (record.gender === 'MALE' ? '男' : '女'),
        },
      );
    },
  },
  {
    label: '状态',
    prop: 'disabled',
    render({ row: record }) {
      return h(
        ElTag,
        {
          type: record.disabled ? 'danger' : 'success',
        },
        {
          default: () => (record.disabled ? '禁用' : '启用'),
        },
      );
    },
  },
  {
    label: '创建时间',
    prop: 'createDate',
  },
];
